package com.company.Sort;

import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}15:38
 */
public class insertSort {
    static int  arr[] = {5,7,6,1,2,3};
    public static void main(String[] args) {
        for (int i = 1; i < arr.length; i++) {
            int insertVAL = arr[i];
            int insertIndex = i - 1;//新数组的下标
            while (insertIndex >= 0 && insertVAL < arr[insertIndex]) {
                arr[insertIndex + 1] = arr[insertIndex];
                insertIndex--;
            }
            arr[insertIndex + 1] = insertVAL;
            System.out.println("第"+i+"轮插入");
            System.out.println(Arrays.toString(arr));
        }
    }
}
